using System;
using System.Linq;

namespace SAP.BusinessOne.Mackinac.Generator.Model
{
    public class Namespace : IComparable
    {
        public Namespace(Type target)
        {
            var ns = target.Namespace.Split('.');
            BeginTag = string.Join("", ns.Select(p => "namespace " + p.ToLower() + " { ").ToArray());
            EndTag = string.Join("", ns.Select(p => "}").ToArray());
        }

        public string BeginTag { get; private set; }
        public string EndTag { get; private set; }

        public int CompareTo(object obj)
        {
            return BeginTag.CompareTo(((Namespace)obj).BeginTag);
        }

        public override bool Equals(object obj)
        {
            return BeginTag == ((Namespace)obj).BeginTag;
        }

        public override int GetHashCode()
        {
            return BeginTag.GetHashCode();
        }
    }
}